package com.csun.cmny.provider.controller.admin;

import com.csun.cmny.core.support.BaseController;
import com.csun.cmny.provider.model.dto.hintColor.DmcHintColorDto;
import com.csun.cmny.provider.model.vo.DmcHintColorVo;
import com.csun.cmny.provider.resolver.CmnyMessageSource;
import com.csun.cmny.provider.service.DmcHintService;
import com.csun.cmny.util.wrapper.WrapMapper;
import com.csun.cmny.util.wrapper.Wrapper;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2019-02-25 13:29
 * @Description: the class dmc device alert controller
 */
@RestController
@RequestMapping(value = "/hint", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class DmcHintController extends BaseController {



    @Resource
    private DmcHintService dmcHintService;
    @Resource
    private CmnyMessageSource cmnyMessageSource;



    /**
     * 查询提示类型和对应颜色
     */
    //@LogAnnotation(isSaveResponseData = true, isSaveRequestData = true)
    @RequestMapping(value = "/hintColor", method = RequestMethod.POST)
    public Wrapper selectHintColor() {


        List<DmcHintColorVo> dmcHintColorVos = dmcHintService.selectAll(getLoginAuthDto().getGroupId());

       // return WrapMapper.ok(dmcHintColorVos);
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,cmnyMessageSource.getMessage("operation.success", null),dmcHintColorVos);
    }

    /**
     * 查询提示类型和对应颜色
     */
   // @LogAnnotation(isSaveResponseData = true, isSaveRequestData = true)
    @RequestMapping(value = "/updateHintColor", method = RequestMethod.POST)
    public Wrapper updateHintColor(@RequestBody List<DmcHintColorDto> dmcHintColorDtoList) {




        Integer result=dmcHintService.updateHintColor(dmcHintColorDtoList,getLoginAuthDto().getGroupId());

       // return WrapMapper.ok(result);
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,cmnyMessageSource.getMessage("operation.success", null),result);
    }

    /**
     * 新增提示类型和对应颜色
     */
   // @LogAnnotation(isSaveResponseData = true, isSaveRequestData = true)
    @RequestMapping(value = "/addHintColor", method = RequestMethod.POST)
    public Wrapper addHintColor(@RequestBody List<DmcHintColorDto> dmcHintColorDtoList) {

        for (DmcHintColorDto dmcHintColorDto : dmcHintColorDtoList) {
            dmcHintColorDto.setGroupId(getLoginAuthDto().getGroupId());
        }


        Integer result=dmcHintService.addHintColor(dmcHintColorDtoList);

       // return WrapMapper.ok(result);
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE,cmnyMessageSource.getMessage("operation.success", null),result);
    }




}
